﻿using JSLCloud.App.Mes.Service;
using Microsoft.Extensions.DependencyInjection;
using System.Threading.Tasks;

namespace JSLCloud.App.Mes.Extentions
{
    /// <summary>
    /// IServiceCollection扩展类
    /// </summary>
    public static class IServiceCollectionExtention
    {
        /// <summary>
        /// 启动后台线程
        /// </summary>
        /// <param name="services"></param>
        /// <param name="service"></param>
        public static void AddBackThread<T>(this IServiceCollection services, T service) where T : IBackThreadService
        {
            Task.Factory.StartNew(() =>
            {
                service.Start();
            });
        }
    }
}
